//
//  WBNavController.swift
//  CustomWeiBo
//
//  Created by laiqiang on 21/5/9.
//  Copyright © 2021年 laiqiang. All rights reserved.
//

import UIKit

class WBNavController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()

        //默认隐藏
        navigationBar.isHidden = true
        // Do any additional setup after loading the view.
    }

    //pushViewController是被push的，设置它的左侧按钮为返回按钮
    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        
        if childViewControllers.count > 0 {
            
            viewController.hidesBottomBarWhenPushed = true
            
            if let vc = viewController as? WBBasController {
                
                var title = " 返回"//nav_back
                if childViewControllers.count == 1 {
                    
                    title = "  " + (childViewControllers.first?.title ?? "返回")
                }
                
                vc.navItem.leftBarButtonItem = UIBarButtonItem(title:title, font: 16, targe: self, action: #selector(viewcontrollerpop), isBack:true)
            }
        }
        

        
        super.pushViewController(viewController, animated: animated)
    }
    
    @objc func viewcontrollerpop(){
        self.popViewController(animated: true)
    }

}
